<template>
	<div class="login_bg">
		<div class="login-container">
			<div class="login-header">
				<h1>Spark进销存</h1>
			</div>

			<div class="login-card">
				<div class="login-welcome">
					<h2>欢迎登录</h2>
					<p>请输入您的账号和密码</p>
				</div>
				<password-form></password-form>
			</div>

			<div class="login-features">
				<div class="feature-item">
					<div class="feature-icon">📊</div>
					<div class="feature-text">
						<h3>实时库存管理</h3>
						<p>精准掌握库存动态，智能预警提醒</p>
					</div>
				</div>
				<div class="feature-item">
					<div class="feature-icon">💰</div>
					<div class="feature-text">
						<h3>进销存一体化</h3>
						<p>采购、销售、库存全流程管理</p>
					</div>
				</div>
				<div class="feature-item">
					<div class="feature-icon">📈</div>
					<div class="feature-text">
						<h3>数据分析报表</h3>
						<p>多维度数据分析，决策支持</p>
					</div>
				</div>
			</div>

			<div class="login-footer">
				<p>© 2024 SparkERP 进销存管理系统</p>
			</div>
		</div>
	</div>
</template>

<script>
import passwordForm from "./components/passwordForm";

export default {
	components: {
		passwordForm,
	},
	data() {
		return {
			config: {
				lang: this.$TOOL.data.get("APP_LANG") || this.$CONFIG.LANG,
				dark: this.$TOOL.data.get("APP_DARK") || false,
			},
			lang: [
				{
					name: "简体中文",
					value: "zh-cn",
				},
				{
					name: "English",
					value: "en",
				},
			],
			WechatLoginCode: "",
			showWechatLogin: false,
			isWechatLoginResult: false,
		};
	},
	watch: {
		"config.dark"(val) {
			if (val) {
				document.documentElement.classList.add("dark");
				this.$TOOL.data.set("APP_DARK", val);
			} else {
				document.documentElement.classList.remove("dark");
				this.$TOOL.data.remove("APP_DARK");
			}
		},
		"config.lang"(val) {
			this.$i18n.locale = val;
			this.$TOOL.data.set("APP_LANG", val);
		},
	},
	created: function () {
		this.$TOOL.data.remove("SELLER_TOKEN");
		this.$TOOL.data.remove("SELLER_USER_INFO");
		this.$TOOL.data.remove("SELLER_MENU");
		this.$TOOL.data.remove("PERMISSIONS");
		this.$TOOL.data.remove("grid");
		this.$store.commit("clearViewTags");
		this.$store.commit("clearKeepLive");
		this.$store.commit("clearIframeList");
	},
	methods: {
		configDark() {
			this.config.dark = this.config.dark ? false : true;
		},
		configLang(command) {
			this.config.lang = command.value;
		},
		wechatLogin() {
			this.showWechatLogin = true;
			this.WechatLoginCode =
				"SCUI-823677237287236-" + new Date().getTime();
			this.isWechatLoginResult = false;
			setTimeout(() => {
				this.isWechatLoginResult = true;
			}, 3000);
		},
	},
};
</script>

<style scoped>
.login_bg {
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #e6f2ff 0%, #cce7ff 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	position: relative;
}
.login-container {
	width: 100%;
	max-width: 1200px;
	padding: 40px 20px;
	display: flex;
	flex-direction: column;
	align-items: center;
	position: relative;
	z-index: 1;
}
.login-header {
	text-align: center;
	margin-bottom: 40px;
}
.login-header h1 {
	font-size: 42px;
	color: #0170FE;
	font-weight: 700;
	letter-spacing: 1px;
}
.login-card {
	width: 100%;
	max-width: 420px;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
	padding: 40px;
	border: 1px solid rgba(255, 255, 255, 0.1);
}
.login-welcome {
	text-align: center;
	margin-bottom: 32px;
}
.login-welcome h2 {
	font-size: 24px;
	color: #333;
	margin-bottom: 8px;
	font-weight: 600;
}
.login-welcome p {
	font-size: 14px;
	color: #666;
}
.login-features {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 24px;
	width: 100%;
	max-width: 1000px;
	margin-top: 20px;
}
.feature-item {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	padding: 20px;
	background: rgba(255, 255, 255, 0.95);
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	transition: all 0.3s ease;
}
.feature-item:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
	border-color: rgba(255, 255, 255, 0.3);
}
.feature-icon {
	font-size: 24px;
	width: 48px;
	height: 48px;
	background: linear-gradient(135deg, #0170FE 0%, #0052cc 100%);
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: #fff;
}
.feature-text h3 {
	color: #333;
	font-size: 16px;
	margin-bottom: 6px;
	font-weight: 600;
}
.feature-text p {
	color: #666;
	font-size: 14px;
	line-height: 1.5;
}
.login-footer {
	text-align: center;
	margin-top: 40px;
}
.login-footer p {
	font-size: 14px;
	color: #666;
}

.login-card:deep(.el-form-item) {
	margin-bottom: 24px;
}

.login-card:deep(.el-input__inner) {
	height: 48px;
	border-radius: 8px;
	border: 1px solid #e0e6ed;
	padding: 0 16px;
	font-size: 14px;
}

.login-card:deep(.el-input__inner:focus) {
	border-color: #0170FE;
	box-shadow: 0 0 0 3px rgba(1, 112, 254, 0.1);
}

.login-card:deep(.el-button--primary) {
	height: 48px;
	border-radius: 8px;
	font-size: 16px;
	font-weight: 500;
	background: linear-gradient(135deg, #0170FE 0%, #0052cc 100%);
	border: none;
}

.login-card:deep(.el-button--primary:hover) {
	background: linear-gradient(135deg, #0052cc 0%, #0041a3 100%);
}

.login-card:deep(.el-button--primary):active {
	background: linear-gradient(135deg, #0041a3 0%, #003080 100%);
}

@media (max-width: 768px) {
	.login-container {
		padding: 20px 16px;
		gap: 30px;
	}
	.login-header h1 {
		font-size: 32px;
	}
	.login-card {
		padding: 30px 20px;
	}
	.login-welcome h2 {
		font-size: 22px;
	}
	.login-features {
		grid-template-columns: 1fr;
		gap: 16px;
	}
	.feature-item {
		padding: 16px;
	}
	.feature-icon {
		width: 40px;
		height: 40px;
		font-size: 20px;
	}
	.feature-text h3 {
		font-size: 15px;
	}
	.feature-text p {
		font-size: 13px;
	}
}

@media (max-width: 480px) {
	.login-header h1 {
		font-size: 28px;
	}
	.login-card {
		padding: 24px 16px;
	}
}
</style>
